using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.Web.Mvc;
namespace CoreData
{
    /// <summary>
    /// Core data class
    /// Code by: Linh Pham
    /// </summary>
    public class Merchant
    {
            public long ID{get;set;}
            public string MerchantName { get; set; }
            public string Logo { get; set; }
            public long UserID{get;set;}
            public long PlanID{get;set;}
            public DateTime RegisterDate{get;set;}
            public DateTime ActiveDate{get;set;}
            public string Note{get;set;}
            public int Balance{get;set;}
            public int Status{get;set;}
            public string MetaTitle{get;set;}
            public string MetaKeyword{get;set;}
            public string MetaDescription{get;set;}
            public bool Active{get;set;}
            public string PlansExt { get; set; }
            public string UserNameExt { get; set; }
            public string EmailExt { get; set; }
            public List<SelectListItem> ListPlanExt { get; set; }
            public List<SelectListItem> ListMerchantStatusExt { get; set; }
            public List<SelectListItem> ListAccountExt { get; set; }
        public Merchant()
        {       
                    Note ="";   
                    MetaTitle ="";   
                    MetaKeyword ="";   
                    MetaDescription ="";   
        }
        
       static Merchant DynamicCast<T>(object row_data, object row_header) where T : Merchant
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Merchant ret = new Merchant();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "UserID":
                        ret.UserID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "PlanID":
                        ret.PlanID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "RegisterDate":
                        ret.RegisterDate = ConvertObject.ToDateTime(dt[column]);
                       break;
                      case  "ActiveDate":
                        ret.ActiveDate = ConvertObject.ToDateTime(dt[column]);
                       break;
                      case  "Note":
                        ret.Note = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Balance":
                        ret.Balance = ConvertObject.ToInt(dt[column]);
                       break;
                      case  "Status":
                        ret.Status = ConvertObject.ToInt(dt[column]);
                       break;
                      case  "MetaTitle":
                        ret.MetaTitle = ConvertObject.ToString(dt[column]);
                       break;
                      case  "MetaKeyword":
                        ret.MetaKeyword = ConvertObject.ToString(dt[column]);
                       break;
                      case  "MetaDescription":
                        ret.MetaDescription = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                   case "UserName":
                       ret.UserNameExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Email":
                       ret.EmailExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "PlansNane":
                       ret.PlansExt = ConvertObject.ToString(dt[column]);
                       break;
                   case "Logo":
                       ret.Logo = ConvertObject.ToString(dt[column]);
                       break;
                   case "MerchantName":
                       ret.MerchantName = ConvertObject.ToString(dt[column]);
                       break;
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}

